<?php
$_GET['catid'] = empty($_GET['catid']) ? '' :intval($_GET['catid']);

$news_categorys = cache_read('news_categorys.php');
if(empty($_GET['catid'])){
	if(empty($_GET['mark'])){
		$_GET['catid'] = 5;
	}else{
		if(array_key_exists($_GET['mark'], $news_categorys['category_mark_id_list'])){
			$_GET['catid'] = $news_categorys['category_mark_id_list'][$_GET['mark']];
		}
	}
	
}
if($_GET['catid'] > 0){
	$_category_info = $news_categorys['category_list'][$_GET['catid']];
	if(isset($_category_info['subcats_list'])){
		$subcats = $_category_info['subcats_list'];
		// $subcats[] = $_GET['catid'];
		$subcats = implode(',', $subcats);
		$_GET['kept'] = " AND `catid` IN ({$subcats})";
		unset($_GET['catid']);
	}
}

// 新闻列表
$oNews = new News();
$news_list = $oNews->get_list('*', $_GET, array('rank' => 'DESC', 'id' => 'DESC'), $__page, $__pagesize = 20);
foreach($news_list['list'] as $key => $news){
	$news['category'] = $news_categorys['category_list'][$news['catid']]['name'];
	$news['publishtime'] = empty($news['updatetime']) ? fdate($news['addtime']) : fdate($news['updatetime']);
	if(empty($news['url'])){
		if($__f_sysvars['url_rewrite'] == 'html' || $__f_sysvars['url_rewrite'] == 'rewrite'){
			if(empty($news['filename'])){
				$news['url'] = PUB_DIR.'news/'.time_to_path($news['addtime']).'/'.$news['id'].'.html';
			}else{
				$news['url'] = PUB_DIR.'news/'.$news['filename'].'.html';
			}
		}else{
			$news['url'] = WEB_DIR."index.php?mdl=news&do=view&id={$news['id']}";
		}
	}
	$news_list['list'][$key] = $news;
}
$vars['news_list'] = $news_list['list'];
$vars['pagelist'] = $news_list['pagelist'];

/*******************************************************************************
 * 页面信息　& 当前位置
 *******************************************************************************/
if($__f_sysvars['url_rewrite'] == 'html' || $__f_sysvars['url_rewrite'] == 'rewrite'){
	if(empty($_category_info)){
		url_here('全部分类', PUB_DIR."news/");
	}else{
		url_here($_category_info['name'], PUB_DIR."news/{$_category_info['mark']}/");
	}
}else{
	if(empty($_category_info)){
		url_here('全部分类', WEB_DIR."index.php?mdl=news");
	}else{
		url_here($_category_info['name'], WEB_DIR."index.php?mdl=news&mark={$_category_info['mark']}");	
	}
}
?>